<?php


namespace app\mall\controller;


use app\data\controller\api\Auth;
use app\mall_back\model\GoodsLuckyDrawModel;

class GoodsLuckyDraw extends Auth
{
    /**
     * 往期揭晓
     */
    public function luckyDrawOld()
    {
        $id   = $this->request->get('id');
        $limit = $this->request->get('limit');

        $info = GoodsLuckyDrawModel::find($id);
        $query = GoodsLuckyDrawModel::where(['status' => GoodsLuckyDrawModel::STATE_FINISHED])
            ->with(['user'])
            ->order('id', 'DESC');
        if (!empty($info->sequence_no)) {
            $query->where(['sequence_no' => $info->sequence_no]);
        } else {
            $query->where('id', $id);
        }

        $list = $query->paginate($limit);

        $this->success('获取成功', $list);
    }


}